package file;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Objects;

/**
 * 内容写入file文件中
 */
public class WriteFile {
	/**
	 * 文件写入
	 * @param filePath
	 * @param fileContent
	 */
	public void write(String filePath, String fileContent) {
        PrintWriter printWriter = null;
        String textToBeWritten = fileContent;
        try {
            printWriter = new PrintWriter(filePath);
        } catch (FileNotFoundException e) {
            System.out.println("Unable to locate the fileName: " + e.getMessage());
        }
        Objects.requireNonNull(printWriter).println(textToBeWritten);
        printWriter.close();
    }
}
